<template>
<el-dialog title="登录"  :visible.sync="dialogFormVisible">
    <el-form :model="form">
        <el-form-item label="用户名" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="密码" :label-width="formLabelWidth">
        <el-input type="password" v-model="form.password" autocomplete="off"></el-input>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="login">确 定</el-button>
    </div>

    

</el-dialog>
</template>
<script>

    export default {
        data() {
        return {
            dialogFormVisible: true,
            form: {
            name: '',
            password:''
            },
            formLabelWidth: '120px'
        };
        },
        methods: {
            login(){
                const url = "http://localhost:9090/user/login"
               
                this.axios.get(url,
                {
                    params:{
                        "name": this.form.name,
                        "password": this.form.password
                    }
                }
            ).then(res=>{
                console.log(res.data);
                if(res.data.code==1){
                    this.$message({
                        message:res.data.msg,
                        type:"success"
                    });
                    this.dialogFormVisible=false

                }else{
                    this.$message.error(res.data.msg)
                }
            }
            ).catch(
                error=>{
                    this.$message.error("登录失败")
                }
            )
            }
        },
    };
</script>
<style>

</style>